<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>聊聊tbox的代码风格</title>
    <meta name="description" content="每个开发者在写了一段时间代码后，都会有自己一套适合自己的代码规范。最近，也看到很多人聊起这些风格上的事，什么命名规则那个好啊，什么的。。这些我个人不做评价，每个人观点和审美观都不一样，永远都争不出一个结果来，其实只要代码看着简洁明了，整个项目的规范统一就行了。。这里，我只说说我在写tbox时候，对于一些代码规范上...">

    
    <meta name="keywords" content="tbox,代码风格,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/2016/07/29/code-style/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>聊聊tbox的代码风格</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2016-07-29
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#tbox" title="Category: tbox" rel="category">tbox</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#tbox" title="Tag: tbox" rel="tag">tbox</a-->
        <a href="/cn/tag/#tbox" title="Tag: tbox" rel="tag">tbox</a>&nbsp;
    
        <!--a href="/tag/#%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC" title="Tag: 代码风格" rel="tag">代码风格</a-->
        <a href="/cn/tag/#代码风格" title="Tag: 代码风格" rel="tag">代码风格</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p>每个开发者在写了一段时间代码后，都会有自己一套适合自己的代码规范。</p>

<p>最近，也看到很多人聊起这些风格上的事，什么命名规则那个好啊，什么的。。</p>

<p>这些我个人不做评价，每个人观点和审美观都不一样，永远都争不出一个结果来，其实只要代码看着简洁明了，整个项目的规范统一就行了。。</p>

<p>这里，我只说说我在写tbox时候，对于一些代码规范上的一些个人经验，以及其演进过程。。</p>

<h3 id="命名规则">命名规则</h3>

<p>tbox的命名规则偏unix化些，主要以<code class="highlighter-rouge">小写+下划线</code>为主，很多人也许还是比较喜欢匈牙利、驼峰法什么的。这个主要还是看个人喜好，以及具体的项目。。</p>

<p>如果项目已经成型，里面已经自成规范，那么往里加代码的时候，还是配合项目风格，来命名比较好，这样整体看上去比较统一规范。。</p>

<p>不过我的大部分个人项目，都是一个人从零写起的，也就没这个约束，个人偏爱unix风格而已，看着挺舒服的。。</p>

<p>其实早期我也是从写mfc开始的，那个时候我命名规则，也习惯加个大写的<code class="highlighter-rouge">C</code>的什么的</p>

<p>后来为了写库，纠结了一阵子命名的问题，每次都为什么时候该大写，什么时候该小写纠结半天，然后敲代码经常要切换大小写，好麻烦，本人又很懒，怎么办呢。。</p>

<p>后来索性不纠结了，算了，还是全小写吧，不纠结大小写问题，由于不需要每次切换大小写，敲代码也更加行云流水了。再配合vim的supertab，哈哈，爽嗨了。。</p>

<h3 id="缩进问题">缩进问题</h3>

<p>早期tbox用的是基于tab的缩进规则，一直持续了几年，后来代码移交github维护后，发现了个大问题，哎呀，排版好乱。。</p>

<p>然后开始各种纠结，各种折腾，无果，最后妥协了，全部改用4个空格的缩进，并且把vim的默认缩进规则也改成了space4</p>

<h3 id="类型问题">类型问题</h3>

<p>为了做到跨平台，tbox中用到的所有类型，都是全部重定义过的，例如：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">typedef</span> <span class="kt">signed</span> <span class="kt">int</span>                  <span class="n">tb_int_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">unsigned</span> <span class="kt">int</span>                <span class="n">tb_uint_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">signed</span> <span class="kt">short</span>                <span class="n">tb_short_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">unsigned</span> <span class="kt">short</span>              <span class="n">tb_ushort_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_int_t</span>                    <span class="n">tb_bool_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">signed</span> <span class="kt">char</span>                 <span class="n">tb_int8_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_int8_t</span>                   <span class="n">tb_sint8_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">unsigned</span> <span class="kt">char</span>               <span class="n">tb_uint8_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_short_t</span>                  <span class="n">tb_int16_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_int16_t</span>                  <span class="n">tb_sint16_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_ushort_t</span>                 <span class="n">tb_uint16_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_int_t</span>                    <span class="n">tb_int32_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_int32_t</span>                  <span class="n">tb_sint32_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_uint_t</span>                   <span class="n">tb_uint32_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">char</span>                        <span class="n">tb_char_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_int32_t</span>                  <span class="n">tb_uchar_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_uint8_t</span>                  <span class="n">tb_byte_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">void</span>                        <span class="n">tb_void_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_void_t</span><span class="o">*</span>                  <span class="n">tb_pointer_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_void_t</span> <span class="k">const</span><span class="o">*</span>            <span class="n">tb_cpointer_t</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">tb_pointer_t</span>                <span class="n">tb_handle_t</span><span class="p">;</span>
</code></pre>
</div>

<p>对于这种方式，褒贬不一，也有人反馈过，这样太过于侵入式了，但是我在tbox中这么使用的原因：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>主要还是为了解决平台统一问题，以及代码一致性。。
</code></pre>
</div>

<p>因为，很多平台的libc支持不是很完整，像<code class="highlighter-rouge">uint32_t</code>这种，每个平台typedef的方式都不相同，如果你的库用到了<code class="highlighter-rouge">uint32_t</code></p>

<p>并且在其他平台的工程上使用，有时候会发现，<code class="highlighter-rouge">uint32_t</code>居然没有定义，或者typedef的不一样，导致编译报错，就很郁闷了。。这种问题我碰到的太多了。。</p>

<p>其中windows平台上最为典型，long在64bits上居然也是4bytes，而且定义方式有好几种，<code class="highlighter-rouge">long</code> 或者 <code class="highlighter-rouge">LONG</code> 等等。。</p>

<p>我在很多其他项目的代码里面，发现有些代码还混着使用，调用处用的是LONG，函数定义用的是long。。</p>

<p>又或者，返回值是<code class="highlighter-rouge">TRUE</code>，判断的时候用的确是<code class="highlighter-rouge">true</code>，汗~~</p>

<p>因此，tbox里面为了不想过多的纠结这些问题，就全部统一处理了，布尔返回值，也一并使用：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define tb_true     ((tb_bool_t)1)
#define tb_false    ((tb_bool_t)0)
</span></code></pre>
</div>

<h3 id="接口设计">接口设计</h3>

<p>tbox里面的接口，也是基于对象式，但是跟c++的那种对象还有些区别的，这里一个对象类型，对应两个文件，这里拿对象<code class="highlighter-rouge">vector</code>为例：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>vector.h
vector.c
</code></pre>
</div>

<p>一个是接口文件，一个是实现文件。。</p>

<h4 id="接口文件">接口文件</h4>

<p>也看下接口文件中的接口定义方式：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>
<span class="c1">// the vector ref type
</span><span class="k">typedef</span> <span class="k">struct</span><span class="p">{}</span><span class="o">*</span>   <span class="n">tb_vector_ref_t</span><span class="p">;</span>

<span class="cm">/*! init vector
 * 
 * @code
 *
    // init vector
    tb_vector_ref_t vector = tb_vector_init(0, tb_element_str(tb_true));
    if (vector)
    {
        // insert elements into head
        tb_vector_insert_head(vector, "hi!");

        // insert elements into tail
        tb_vector_insert_tail(vector, "how");
        tb_vector_insert_tail(vector, "are");
        tb_vector_insert_tail(vector, "you");

        // dump elements
        tb_for_all (tb_char_t const*, cstr, vector)
        {
            // trace
            tb_trace_d("%s", cstr);
        }

        // exit vector
        tb_vector_exit(vector);
    }
 * @endcode
 *
 * @param grow      the item grow
 * @param element   the element
 *
 * @return          the vector
 */</span>
<span class="n">tb_vector_ref_t</span>     <span class="n">tb_vector_init</span><span class="p">(</span><span class="n">tb_size_t</span> <span class="n">grow</span><span class="p">,</span> <span class="n">tb_element_t</span> <span class="n">element</span><span class="p">);</span>

<span class="cm">/*! exist vector
 *
 * @param vector    the vector
 */</span>
<span class="n">tb_void_t</span>           <span class="n">tb_vector_exit</span><span class="p">(</span><span class="n">tb_vector_ref_t</span> <span class="n">vector</span><span class="p">);</span>

<span class="cm">/*! insert the vector tail item
 *
 * @param vector    the vector
 * @param data      the item data
 */</span>
<span class="n">tb_void_t</span>           <span class="n">tb_vector_insert_tail</span><span class="p">(</span><span class="n">tb_vector_ref_t</span> <span class="n">vector</span><span class="p">,</span> <span class="n">tb_cpointer_t</span> <span class="n">data</span><span class="p">);</span>
</code></pre>
</div>

<p>在tbox里面，每个接口，都是有注释的，注释规范用的是doxygen的格式，并且对于一些接口的是有，我会加上如何调用的demo例子在注释中</p>

<p>这样，一般情况下，只需要看注释，就知道怎么用接口了，并且为了不想中英文切换，我注释也都是英文的，虽然我英文很菜，有很多语法问题。。：）</p>

<p>尤其需要说一下的是，这里的类型定义：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">typedef</span> <span class="k">struct</span><span class="p">{}</span><span class="o">*</span>   <span class="n">tb_vector_ref_t</span><span class="p">;</span>
</code></pre>
</div>

<p>很多人也奇怪，我为什么要这么写，其实早期我不是这么写的，以前的写法是：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">typedef</span> <span class="k">struct</span> <span class="n">__tb_vector_t</span>
<span class="p">{</span>
    <span class="c1">// the data size
</span>    <span class="n">tb_size_t</span>   <span class="n">size</span><span class="p">;</span>

    <span class="c1">// the data buffer
</span>    <span class="n">tb_byte_t</span><span class="o">*</span>  <span class="n">data</span><span class="p">;</span>

    <span class="c1">// ...
</span>
<span class="p">}</span><span class="n">tb_vector_t</span><span class="p">,</span> <span class="o">*</span><span class="n">tb_vector_ref_t</span><span class="p">;</span>
</code></pre>
</div>

<p>但是这样，会有个问题，因为把struct的成员暴露在了头文件中，很容易导致版本更新的时候，struct定义跟库接口不一致，产生一些莫名的问题。。</p>

<p>而且，这样容易使得别人去乱改里面的数据成员，但是这个成员应该是私有的，不能直接让别人访问的，要想方位，需要暴露接口的方式来访问</p>

<p>因为，我需要吧struct的实际定义隐藏起来，只暴露引用，这样还能解决头文件的<code class="highlighter-rouge">include</code>依赖过于复杂，导致循环<code class="highlighter-rouge">include</code>的问题。</p>

<p>那为什么，是直接定义成：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">typedef</span> <span class="kt">void</span><span class="o">*</span> <span class="n">tb_vector_ref_t</span><span class="p">;</span>
</code></pre>
</div>

<p>这种呢，这种方式，相当于去类型化了，把强类型削弱了，会导致一个vector对象，不小心传给<code class="highlighter-rouge">tb_list_remove</code>的接口，编译也不会报错。</p>

<p>使得容易产生一些隐藏bug，到时候很难查，为了让编译器能及时报错，必须要保证强类型检测生效，因此我才采用了这种方式定义：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">typedef</span> <span class="k">struct</span><span class="p">{}</span><span class="o">*</span> <span class="n">tb_vector_ref_t</span><span class="p">;</span>
</code></pre>
</div>

<h4 id="实现文件">实现文件</h4>

<p>接口实现中，我们才会去真正的定义这个vector对象的具体成员结构，例如：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">typedef</span> <span class="k">struct</span> <span class="n">__tb_vector_t</span>
<span class="p">{</span>
    <span class="c1">// the data size
</span>    <span class="n">tb_size_t</span>   <span class="n">size</span><span class="p">;</span>

    <span class="c1">// the data buffer
</span>    <span class="n">tb_byte_t</span><span class="o">*</span>  <span class="n">data</span><span class="p">;</span>

    <span class="c1">// ...
</span>
<span class="p">}</span><span class="n">tb_vector_t</span><span class="p">;</span>

<span class="c1">// 这里第一个参数名为self，相当于c++的this，表示当前对象实例的引用
</span><span class="n">tb_void_t</span> <span class="nf">tb_vector_exit</span><span class="p">(</span><span class="n">tb_vector_ref_t</span> <span class="n">self</span><span class="p">)</span>
<span class="p">{</span>
    <span class="c1">// tbox的每个接口开头，都会加上assert进行断言检测
</span>    <span class="c1">// 在debug下第一时间报告出现的问题，release下会禁用，不影响性能
</span>    <span class="n">tb_vector_t</span><span class="o">*</span> <span class="n">vector</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_vector_t</span><span class="o">*</span><span class="p">)</span><span class="n">self</span><span class="p">;</span>
    <span class="n">tb_assert_and_check_return</span><span class="p">(</span><span class="n">vector</span><span class="p">);</span>

    <span class="c1">// exit data
</span>    <span class="k">if</span> <span class="p">(</span><span class="n">vector</span><span class="o">-&gt;</span><span class="n">data</span><span class="p">)</span> <span class="n">tb_free</span><span class="p">(</span><span class="n">data</span><span class="p">);</span>
    <span class="n">vector</span><span class="o">-&gt;</span><span class="n">data</span> <span class="o">=</span> <span class="n">tb_null</span><span class="p">;</span>
    <span class="n">vector</span><span class="o">-&gt;</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>

<p>另外，如果看到tbox里面有些地方，并不是按照上面的规范来的，也不用奇怪，毕竟这项目我陆陆续续写了很多年，有些历史遗留代码，可能没有及时更新，有时间的话，我会改掉。</p>

        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        

        
        
            
        
            
            
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
                
                    
                
                    
                
            
            
        
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/2016/07/28/hnr-split-image/">手写数字识别系统之图像分割</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2016/07/29/next-plan/">关于xmake下一步的开发计划</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
